package com.dormitory.Servlet;
import com.dormitory.dao.selectInformation;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/editBuilding")
public class editBuilding extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html; charset=UTF-8");
        String buildingnub=req.getParameter("buildingnub");
        String state=req.getParameter("state");
        selectInformation selectInformation =new selectInformation();
        if (state.equals("1")){
            selectInformation.postStudent("update building set 状态='满' where 寝室号="+"'"+buildingnub+"'");
        }
        else if (state.equals("0")){
            selectInformation.postStudent("update building set 状态='缺' where 寝室号="+"'"+buildingnub+"'");
        }
    }
}
